//
//  ToolViewController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/18.
//  Copyright © 2017年 test. All rights reserved.
//

#import "ToolViewController.h"
#import "UIButton+ImageTitleSpacing.h"
#import "UIButton+ImageTitleSpacing.h"

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
//屏幕宽度
#define windowWidth [UIScreen mainScreen].bounds.size.width
//屏幕高度
#define windowHeight [UIScreen mainScreen].bounds.size.height

@interface ToolViewController ()

@end

@implementation ToolViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self getUI];
}


#pragma mark = Private Method
- (void)getUI{
    NSArray *titleArray = @[@"审批",@"财务审批",@"文件",@"消息",@"联系人",@"工具",@"消息",@"联系人",@"工具"];
    NSArray *imageArray = @[@"mess",@"mess",@"book",@"mess",@"mess",@"book",@"mess",@"mess",@"book"];
    CGFloat width = (CGFloat)(windowWidth - 13)/3;
    for (int i = 0; i < titleArray.count; i++) {
        [self.view layoutIfNeeded];
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(3+width*(i%3)+3*(i%3), 3+width*(i/3)+3*(i/3) + 64, width, width)];
        button.titleLabel.textColor = [UIColor whiteColor];
        button.backgroundColor = RGBCOLOR(42+i, 155+i, 255);
        [button setTitle:titleArray[i] forState:0];
        [button setImage:[UIImage imageNamed:imageArray[i]] forState:0];
        [button layoutButtonWithEdgInsetsStyle:WxyButtonEdgeInsetsStyleImageTop imageTitleSpacing:10];
        [self.view addSubview:button];
        button.tag = 10+i;
        [button addTarget:self action:@selector(chooseView:) forControlEvents:UIControlEventTouchUpInside];
        NSLog(@"logRect = %@", NSStringFromCGRect(button.frame));
        
    }

}

#pragma mark - ButtonTarget
- (void)chooseView:(UIButton *)sender{
    if (sender.tag == 10) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 11) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 12) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 13) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 14) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 15) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 16) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 17) {
        NSLog(@"%ld",(long)sender.tag);
    }
    else if (sender.tag == 18) {
        NSLog(@"%ld",(long)sender.tag);
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
